package com.its.classOrder.controller;

import com.its.classOrder.pojo.ClassOrder;
import com.its.classOrder.service.ClassOrderService;
import com.its.domain.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/classOrder")
public class ClassOrderController {
    //依赖注入Service层属性
    @Autowired
    private ClassOrderService classOrderService;

    //新增报名信息
    @PostMapping("/add")
    public BaseResult addClassOrder(@RequestBody ClassOrder classOrder){
        return BaseResult.ok(classOrderService.addClassOrder(classOrder));
    }

    //删除报名表信息
    @DeleteMapping("/delete")
    public BaseResult deleteClassOrder(Integer classOrderId){
        return BaseResult.ok(classOrderService.deleteClassOrder(classOrderId));
    }

    //修改报名表信息
    @PutMapping("/update")
    public BaseResult updateClassOrder(@RequestBody ClassOrder classOrder){
        return BaseResult.ok(classOrderService.updateClassOrder(classOrder));
    }

    //根据会员账号查询报名表信息
    @GetMapping("/findByMemberAccount")
    public BaseResult findClassOrderByMemberAccount(Integer memberAccount){
        return BaseResult.ok(classOrderService.selectClassOrderByMemberAccount(memberAccount));
    }

    //根据课程ID查询所有该课程已经报名的会员
    @GetMapping("/findByClassId")
    public BaseResult findClassOrderByClassId(Integer classId){
        return BaseResult.ok(classOrderService.selectMemberOrderByClassId(classId));
    }

    //分页查询所有报名表信息
    @GetMapping("/search")
    public BaseResult getAllClassOrder(Integer page,Integer size){
        return BaseResult.ok(classOrderService.selectAllClassOrder(page, size));
    }
}
